SUBROUTINE prodfunc(imunin,ieduin,zzpuin,zzprin,qcons_out)
  USE commonvars
  IMPLICIT NONE
  INCLUDE 'mpif.h'

  REAL(8), INTENT(IN)  :: zzpuin, zzprin
  INTEGER, INTENT(IN)  :: imunin, ieduin
  REAL(8), INTENT(OUT) :: qcons_out

  !ability_g is a continuos variable drawn from a normal distribution
  !this variable is set in mayordecision, mayorsolution, or mayorsolution0

  ! THE OUTPUT IS PER-CAPITA
  qcons_out = (zzpuin*norm)**alphaq(1)*zzprin**alphaq(2)*EXP(alphaq(3)*DBLE(ieduin)+alphaq(4)+polypop(imunin))*ability_g

!!$  IF (flag_here == 123) write(*,'(a,11f18.10)') 'qcons_out', qcons_out, zzpuin, zzpuin*norm, zzprin, DBLE(ieduin), ability_g, (zzpuin*norm)**alphaq(1), zzprin**alphaq(2), EXP(alphaq(3)*DBLE(ieduin)+alphaq(4)+polypop(imunin)), alphaq(3)*DBLE(ieduin), alphaq(4), polypop(imunin)

END SUBROUTINE prodfunc


